package com.example.service.impl;

import com.example.entity.Menu;
import com.example.entity.PageBean;
import com.example.entity.Worker;
import com.example.mapper.MenuMapper;
import com.example.mapper.WorkerMapper;
import com.example.service.MenuService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;
    @Override
    public Menu findByMenuMname(String mname) {
        Menu menu = menuMapper.findByMenuMname(mname);
        return menu;
    }

    @Override
    public void updata(Menu menu) {
        menuMapper.updata(menu);
    }

    @Override
    public void add(Menu menu) {
        menuMapper.insert(menu);
    }

    @Override
    public void delete(List<Integer> id) {
        menuMapper.delete(id);
    }

    @Override
    public PageBean page(Integer page, Integer pageSize, String menuname, String menuprice) {
        PageHelper.startPage(page,pageSize);
        List<Menu> pageList=menuMapper.selectByPage(menuname,menuprice);
        Page<Menu> p=(Page<Menu>) pageList;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }
}
